package com.util;

import java.text.ParseException;
import java.util.Date;
import java.util.GregorianCalendar;

public class Util {
    public static Date YMDDate(String s) throws ParseException {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd");
        return sdf.parse(s);
    }

    public static Date YMDHMDate(String s) throws ParseException {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd HH:mm");
        return sdf.parse(s);
    }

    public static Date fullDate(String s) throws ParseException {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");
        return sdf.parse(s);

    }

    public static String splitDate(Date d) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd");
        return sdf.format(d);
    }

    public static String splitDate1(Date d) {
        java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
                "yyyy-MM-dd HH:mm");
        return sdf.format(d);
    }

    public static long getPrimeKey() {
        GregorianCalendar calendar = new GregorianCalendar();
        return calendar.getTimeInMillis();
    }

    public static long stringToLong(String source) {
        return Long.parseLong(source);
    }

}
